package com.swagger.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author renzhengxuan
 * @date 2021/5/15
 */
@Configuration
public class SwaggerConfig {

    @Bean
    public Docket sysDocket(){
        return docket("系统用户","com.example.swagger.test1");
    }
    @Bean
    public Docket fileDocket(){
        return docket("文件上传","com.example.swagger.test2");
    }


    private Docket docket(String groupName,String basePackage){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName(groupName)
                .select()
                //指定扫描的包com.example.swagger.test2
                .apis(RequestHandlerSelectors.basePackage(basePackage))
                .build();
    }
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("测试后台api文档")
                .description("后台api")
                //这个contact可写可不写
                .contact(new Contact(null,null,null))
                .version("V1.0")
                .build();
    }
}
